package zyh.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.annotation.WebListener;

//@WebListener
public class MyServletContextAttributeListener implements ServletContextAttributeListener{
    public void attributeAdded(ServletContextAttributeEvent event) {
        ServletContext application=event.getServletContext();
        String name=event.getName();
        Object value=event.getValue();
        System.out.println("application范围内添加了名为"+name+",值为"+value+"  的属性！");
//        System.out.print("系统编码是 " +System.getProperty("file.encoding"));
    }

    public void attributeRemoved(ServletContextAttributeEvent event) {
        ServletContext application=event.getServletContext();
        String name=event.getName();
        Object value=event.getValue();
        System.out.println(application+"范围内名为"+name+",值为"+value+" 的属性被删除了！");
    }

    public void attributeReplaced(ServletContextAttributeEvent event) {
        ServletContext application=event.getServletContext();
        String name=event.getName();
        Object value=event.getValue();
        System.out.println(application+"范围内名为"+name+",值为"+value+"  的属性被替换！");
    }
}
